<?php
namespace app\modules\api\controllers;

use Yii;
use ac\controllers\BasicController;
use app\models\Poster;
use ac\component\tool\Tool;
use ac\component\exception\ErrMap;
use app\models\OperationLog;


class PosterController extends BasicController
{

      /*广告列表*/
    public function actionList()
    {
        $get = Yii::$app->request->get();
        if(isset($get['page'])){
            $currPage = (int)$get['page']?$get['page']:1;
        }else{
            $currPage = 1;
        }
        $poster = new Poster;

        if(isset($this->get['page'])){
            $currPage = intval($this->get['page']?$this->get['page']:1);
        }else{
            $currPage = 1;
        }
        $pageSize = Tool::getPageSize();

        $poster = new Poster;
        $count = $poster::find()->count();
        $posterList = $poster::find()
                        ->orderBy(['sort' => SORT_DESC])
                        ->offset($pageSize*($currPage-1))->limit($pageSize)
                        ->asArray()->all();
        // P($posterList);
        $res = array(
            'list' => $posterList,
            'pageInfo' => array(
                'count' => intval($count),
                'currPage' => $currPage,
                'pageSize' => $pageSize,
            ),
        );
        // P($res);
        return Tool::showRes([0, '获取成功'], $res);

    }

}
